package cn.tedu.oop2;
/**本类用于完成汽车设计案例*/
public class DesignCar {
    public static void main(String[] args) {
        Car c = new Car();
        System.out.println(c.getColor());
        c.start();
        c.stop();

        BWM b = new BWM();
        System.out.println(b.color);
        System.out.println(b.getColor());
        b.start();
        b.stop();

        Car c2 = new TSL();
//        System.out.println(c2.color);//报错因为父类被封装
        System.out.println(c2.getColor());
        c2.stop();//调用父类但是子类重写方法 怎么刹不住
        c2.start();
//        c2.swim();//父类中并没有这个方法的声明

    }
}
class Car{
    private String brand;
    private String color;
    private int id;
    private double price;

    public void start(){
        System.out.println("开上我心爱的小车车");
    }
    public void stop(){
        System.out.println("小车车停下来了");
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }



}
class BWM extends Car{
    String color = "五彩斑斓的黑";
    @Override
    public void start(){
        System.out.println("都让开，我要起飞了");
    }
}
class TSL extends Car{
    String color = "黑不溜秋的白";
    @Override
    public void stop(){
        System.out.println("怎么刹不住");
    }
    public void swim(){
        System.out.println("没有想到吧，我还是个潜水艇");
    }
}